package itheima.d12;

public class Test {
    public static void main(String[] args) {
        System.out.println(isPhone("13888888888"));

    }
    public static boolean isPhone(String phone){

    //排除错误情况
        if(!phone.startsWith("1")){
        System.out.println("手机号必须以1开头");
        return false;
    }
        if(phone.length() != 11){
        System.out.println("手机号必须11位");
        return false;
    }
        if(phone.charAt(1) < '3' || phone.charAt(1) > '9'){
        System.out.println("第二位必须是3/4/5/6/7/8/9");
        return false;
    }
        for(int i = 2; i < phone.length(); i++){
        char c = phone.charAt(i);
        if(c < '0' || c > '9'){
            System.out.println("手机号必须全部是数字");
            return false;
        }
    }
        System.out.println("手机号格式正确");
        return true;
    }
    public static void check(String phone){

    }

}
